<div>
    <header class="navbar navbar-default navbar-fixed-top">
        <div class="row">
            <div id="navbar" class="navbar-collapse collapse col-md-6 col-md-offset-2">
                <ul class="nav navbar-nav">
                    <a class="navbar-brand" href="http://127.0.0.1/">我的博客</a>
                    {% for term in term_list %}
                        <li ><a href="http://127.0.0.1/term/{{ term.id }}/" class="navbar-brand">{{ term }}</a></li>
                    {% endfor %}
                </ul>
            </div>
            <div class="col-md-6">
                {% if request.user.is_authenticated %}
                    <div class="navbar-form navbar-left pull-right">
                        <span>欢迎 {{ request.user.author.name }}</span>
                        <a href="{% url 'create_post' %}" class="btn btn-primary" role="button">发帖</a>
                        <a href="{% url 'logout' %}" class="btn btn-primary" role="button">注销</a>
                    </div>
                {% else %}
                    <form class="navbar-form navbar-left col-md-pull-2 pull-right" role="search" method="post" action="{% url 'login' %}">
                        {% csrf_token %}
                        <div class="form-group">
                           <label for="exampleInputEmail1">用户名:</label>
                           <input type="text" class="form-control" placeholder="Username" name="username">
                       </div>
                       <div class="form-group">
                           <label for="exampleInputEmail1">密码:</label>
                           <input type="password" class="form-control" placeholder="Password" name="password">
                       </div>
                        <button type="submit" class="btn btn-primary">登陆</button>
                        <a href="{% url 'register' %}" class="btn btn-primary" role="button">注册</a>
                    </form>
                {% endif %}
            </div>
        </div>
    </header>
</div>